import { getConfig } from '@/config/api';

const config = getConfig();

export const dark = {
  version: 8,
  sprite: `${config.mapboxAssets}/style/sprite`,
  glyphs: `${config.mapboxAssets}/glyphs/mapbox/{fontstack}/{range}.pbf`,
  projection: {
    name: 'globe',
  },
  sources: {
    // 为每个图层创建独立的数据源
    // osm_world: {
    //   type: 'raster',
    //   tiles: [
    //     // `${config.geoServer}/gwc/service/tms/1.0.0/ne:world@WebMercatorQuad/png/{z}/{x}/{y}.png`,
    //     // `${config.geoServer}/gwc/service/wmts?layer=ne:world&style=&tilematrixset=EPSG:4326&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:4326:{z}&TileCol={x}&TileRow={y}`,
    //     `${config.geoServer}/gwc/service/wmts?layer=ne:world&style=&tilematrixset=EPSG:900913&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix=EPSG:900913:{z}&TileCol={x}&TileRow={y}`,
    //   ],
    //   tileSize: 256,
    // },
    planet_osm_roads: {
      type: 'vector',
      scheme: 'tms',
      tiles: ['http://localhost:8080/maps/bonn/{z}/{x}/{y}.pbf'],
    },
  },
  layers: [
    // 背景
    {
      id: 'background',
      type: 'background',
      paint: { 'background-color': 'hsl(0, 0%, 16%)' },
    },
    // OSM地图瓦片图层
    // {
    //   id: 'osm_world_layer',
    //   type: 'raster',
    //   source: 'osm_world',
    //   paint: {
    //     'raster-opacity': 0.8,
    //   },
    // },
    {
      id: 'roads_major',
      type: 'line',
      source: 'planet_osm_roads',
      'source-layer': 'planet_osm_roads_layer',
      // filter: ['in', 'highway', 'motorway', 'trunk', 'primary'],
      paint: {
        'line-color': '#555555',
        'line-width': {
          base: 1.2,
          stops: [
            [10, 1],
            [18, 8],
          ],
        },
      },
    },
  ],
};
